package com.zhiyou.serviceimpl;

import java.sql.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhiyou.mapper.SupervisorDormMapper;
import com.zhiyou.model.FYDormAttendance;
import com.zhiyou.service.DormManageService;

@Service
public class DormManageServiceImpl implements DormManageService {

	@Autowired
	SupervisorDormMapper smapper;

	@Override
	public List<LinkedHashMap<String, String>> SelectJuDge(Date date, Integer id) {
		if (id == 1) { // 如果ID为1就根据寝楼ID查询考勤记录
			List<LinkedHashMap<String, String>> list = smapper.SelectByBuilding(date, id);
			List<LinkedHashMap<String, String>> list2 = smapper.SelectByBuildingID(date, id);
			list.addAll(list2);
			return list;
		}
		List<LinkedHashMap<String, String>> list = smapper.SelectByClass(date, id); // 否则则根据教室ID查询考勤记录
		List<LinkedHashMap<String, String>> list2 = smapper.SelectByClassID(date, id);
		list.addAll(list2);
		return list;

	}

	@Override
	public List<Map<String, String>> SelectByBuildingDetails(Integer ids, Integer building_id, Date date,
			Integer dorm_id) {
		if (ids==1) {										//如果传过来的ids等于1,那么就差未归人的信息
			return smapper.SelectByBuildingWeiGui(ids, building_id, date, dorm_id);
		}else if (ids==2) {									//如果传过来的ids等于2,那么就差未归人的信息
			return smapper.SelectByBuildingYiGui(ids, building_id, date, dorm_id);
		}else {												//如果传过来的ids等于3,那么就差未归人的信息
			return smapper.SelectByBuildingQingJia(ids, building_id, date, dorm_id);
		}
	}

	@Override
	public List<Map<String, String>> selectByStudentName(String student_name) {
		
		return smapper.selectByStudentName(student_name);
	}

	

	@Override
	public FYDormAttendance SDormA(Integer student_id, Date dorm_current_date) {
		FYDormAttendance selectByid = smapper.SelectByid(student_id, dorm_current_date);
		selectByid.setIf_not_back(0);
		smapper.updateDrom(selectByid);
		return selectByid;
	}

	

}
